﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NGuice.Inject.Internal.Util;

namespace NGuice.Test
{
    [TestClass]
    public class MapMakerTest
    {
        //    private  static CustomConcurrentDictionary.Impl<K, V, E> MakeCustomMap<K, V, E>(MapMaker maker)
        //        where E:class
        //    {
        //  // Use makeComputingMap() to force it to return CCHM.Impl, not
        //  // ConcurrentHashMap.
        //        return (CustomConcurrentDictionary.Impl<K, V, E>)maker.MakeComputingMap<K, V>((k) =>
        //        {
        //            return k;
        //        });
        //}
        [TestMethod]
        public void SizingDefaultsTest()
        {
            CustomConcurrentDictionary.Impl<object, object, MapMaker.ReferenceEntry<object, object>> map = new MapMaker().MakeComputingMap<object, object>((k) =>
            {
                return k;
            }) as CustomConcurrentDictionary.Impl<object, object, MapMaker.ReferenceEntry<object, object>>;
            Assert.AreEqual(16, map.segments.Length); // concurrency level
            Assert.AreEqual(1, map.segments[0].Table.Length); // capacity / conc level
            Assert.AreEqual(0.75f, map.loadFactor);
        }
    }
}
